package com.wlyuan.open.scanner.repository.impl;

import com.wlyuan.open.scanner.constant.Constants;
import com.wlyuan.open.scanner.dao.mapper.QuotationRelationMapper;
import com.wlyuan.open.scanner.domain.quotation.QuotationRelation;
import com.wlyuan.open.scanner.domain.quotation.QuotationRelationConvert;
import com.wlyuan.open.scanner.repository.QuotationRelationRepository;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import lombok.var;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author lijing
 * @description
 */
@Service
@Slf4j
@RequiredArgsConstructor
public class QuotationRelationRepositoryImpl implements QuotationRelationRepository {
    private final QuotationRelationMapper quotationRelationMapper;

    @Override
    public List<QuotationRelation> list(Integer pageNum, Integer waybillType) {
        var data = quotationRelationMapper.list(pageNum, Constants.PAGE_SIZE, waybillType);
        return QuotationRelationConvert.convert(data);
    }

    @Override
    public List<Long> getByTime(String startTime, String endTime, Integer waybillType) {
        return quotationRelationMapper.getByTime(startTime, endTime, waybillType);
    }

    @Override
    public List<Long> getByTenantIdTime(Long tenantId, String startTime, String endTime, Integer waybillType) {
        return quotationRelationMapper.getByTenantIdTime(tenantId, startTime, endTime, waybillType);
    }

    @Override
    public QuotationRelation getByWaybillId(Long waybillId) {
        return QuotationRelationConvert.convert(quotationRelationMapper.getWaybillId(waybillId));
    }

    @Override
    public List<QuotationRelation> list(Integer pageNum, Long tenantId, Integer waybillType) {
        var data = quotationRelationMapper.listByTenantId(pageNum, Constants.PAGE_SIZE, tenantId, waybillType);
        return QuotationRelationConvert.convert(data);
    }

    @Override
    public Integer count(Integer waybillType) {
        return quotationRelationMapper.count(waybillType);
    }

    @Override
    public Integer count(Long tenantId, Integer waybillType) {
        return quotationRelationMapper.countByTenantId(tenantId);
    }

}
